package com.eascs.web.o2o.dc.common.util;

import java.util.ArrayList;
import java.util.List;

import com.eascs.common.doc.excel.RowWriteHandler;
import com.eascs.common.doc.excel.WriteCell;

public class BankRowWriteHandler implements RowWriteHandler {

	List<Object[]> data;// 数据
	int column;
	int index = 0;
	int[] arr;// 需要统计的列
	List<String> title=null;
	int sheetIndex=0;
	int rowIndex=0;
	int columnIndex=0;
	/*
	 * param:数据，excel显示的列数，需要统计的列，标题，显示数据的表格，开始显示数据的行，开始显示数据的列。（0开始）
	 * 
	 */
	public BankRowWriteHandler(List<Object[]> data, int column, int[] arr,List<String> title,int sheetIndex,int rowIndex,int columnIndex) {
		super();
		this.data = data;
		this.column = column;
		this.arr = arr;
		this.title=title;
		this.sheetIndex=sheetIndex;
		this.rowIndex=rowIndex;
		this.columnIndex=columnIndex;
	}

	@Override
	public int getSheetIndex() {
		return sheetIndex;
	}

	@Override
	public int getRowIndex() {
		return rowIndex;
	}

	@Override
	public int getColumnIndex() {
		return columnIndex;
	}

	@Override
	public Object[] nextRowDatas() {
		if (index < data.size())
			return data.get(index++);
		else
			return null;
	}

	@Override
	public List<WriteCell> getWriteCells() {//设置标题（多标题1）
		ArrayList<WriteCell> list=new ArrayList<WriteCell>();
		if(title!=null&&title.size()>0){
			for (int i = 0; i < title.size(); i++) {
				list.add(new WriteCell(i, 0, title.get(i))) ;
			}
		}
		return list;
	}

	@Override
	public int[] getTotalCols() {
		return arr;
	}

	@Override
	public int getColumnNumber() {
		return column;
	}

	@Override
	public String[] getHeaderCols() {
		return null;
	}

}
